import {
  fromJS,
} from 'immutable';
import * as constants from './constants';

const initialState = fromJS({
  focused: false,
  list: [], // 搜索列表内容
  onMouseIn: false, // 鼠标移入事件
});

export default (state = initialState, action: any) => {
  switch (action.type) {
    case constants.NAV_INPUT_BLUR:
      return state.set('focused', action.value);
    case constants.NAV_INPUT_FOCUSED:
      return state.set('focused', action.value);
    case constants.SEARCHLIST_CHANGE_WHEN_FOCUSED:
      return state.set('list', action.value);
    case constants.SEARCHLIST_MOUSEIN:
      return state.set('onMouseIn', action.value);
    case constants.SEARCHLIST_MOUSEOUT:
      return state.set('onMouseIn', action.value);
    default:
      return state;
  }
};
